package com.chapter02;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;

public class TestConnection4 {
    public static void main(String[] args) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException {

        // todo 准备连接数据库的要素
        String driverClazz = "com.mysql.jdbc.Driver";
        String url = "jdbc:mysql://127.0.0.1:3306/myschool";
        String userName = "root";
        String userPwd = "root";

        // todo 通过反射的方式，创建一个驱动
        Class.forName(driverClazz);

        // todo 通过dirverManager来获取连接对象
        Connection connection = DriverManager.getConnection(url, userName, userPwd);

        // todo 输出连接对象
        System.out.println(connection.getClass().getName());
    }
}
